package common.test;

public class MaxArea {

    public int maxArea(int[] height) {
        if (height == null || height.length == 0) {
            return 0;
        }
        int maxArea = 0;
        for (int i = 0, j = height.length - 1; i < j; ) {
            int y = Math.min(height[i], height[j]);
            int x = j - i;
            maxArea = Math.max(maxArea, (x * y));
            if (height[j] < height[i]) {
                --j;
            } else {
                ++i;
            }
        }
        return maxArea;
    }
}
